<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Payroll Wizard</title>
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<script language="javascript"> 
function transfer(date_begin,date_end){
	window.location.href = 'http://<?php echo WEB_IP?>/rosteraudit/payroll-wizard-calculate-allowance/date_begin/'+ date_begin + '/date_end/' + date_end + '/next/yes';
}
function myFunction() {
    window.print();
}

</script>
</head>

<body style="font-family:Arial, Helvetica, sans-serif">
<?php
$stf = new Model_Payroll_Staffbonus();
$stDetail = new Model_DbTable_Roster_Stafflogindetail();
$stInfo = new Model_DbTable_Roster_Staffinfo();
$btype = new Model_Payroll_Staffbonustype();
$totalC = 0;
$totalB = 0;
$totalAmt = 0;?>
<h1>Payroll Wizard Calculate Bonus</h1>
<h3>Payroll ( <?php echo $this->dateBegin;?> ~ <?php echo $this->dateEnd;?> )</h3>
<?php if($this->link){
		echo "Total ".$this->cashCount."Cash Staff has been generated"."<br/>";
		echo "Total ".$this->bankCount."Bank Staff has been generated"."<br/>";
		echo $this->link."<br/>";?>
	
<?php }?>
<br/>
<br/>

<form action = "" method = "post">
<input type = "submit" id = "export_file" name = "export_file" value = "Export File" onclick="if(confirm('Have you back up your MYOB? If yes click ok')){} else {return false;};"></input>

	<h3>Cash List (Total <?php echo count($this->cashList);?>)</h3>
	<table border="1" cellspacing="0" cellpadding="2" style="font-size:10px;">
		<tr>
			<td style="width:65px;">ID Bonus</td>
   			<td style="width:120px;">Staff</td>
    		<td style="width:150px;">Bonus Type</td>
    		<td style="width:100px;">Total Amt</td>
    		<td style="width:180px;">Period</td>
    		<td style="width:100px;">Will Pay On</td>
    		<td>Status</td>
		</tr>
		<?php foreach($this->cashList as $k => $v){
				$btypeRow = $btype->getStaffbonustype($v['type_bonus']);
		    	$sdRow = $stDetail->getDetail($v['id_staff']);
		    	$stRow = $stInfo->getStaffinfo($v['id_staff']);
		    	$nName = $sdRow['ni'];
		    	$fName = Model_EncryptHelper::getSslPassword($sdRow['n']);
		    	?>
			<tr>
				<td><?php echo $v['id_bonus'];?></td>
				<td><?php echo ucwords($nName." <br />[ ".$fName." ]");?></td>
				<td><?php echo $btypeRow['type_bonus']?></td>
				<td <?php if($stRow['id_package'] == 1 || $stRow['id_package'] == 3 || $stRow['id_package'] == 4 || $stRow['id_package'] == 6 || $stRow['id_package'] == 7 || $stRow['id_package'] == 8){?>style = "background:yellow"<?php }?>>$ <?php echo $v['amt_total_bonus']?> <?php if($stRow['id_package'] == 1 || $stRow['id_package'] == 3 || $stRow['id_package'] == 4 || $stRow['id_package'] == 6 || $stRow['id_package'] == 7 || $stRow['id_package'] == 8){?><span>(Cash to Bank)</span><?php }?></td>
				<td><?php echo $v['period_bonus_begin']." to ".$v['Period_bonus_end'];?></td>
				<td width="20"><?php echo $v['pay_date']?></td>
				<td><?php if($v['payment_status']== 'yes'){echo "PAID";}?></td>
				<?php $totalC += $v['amt_total_bonus'];?>
			</tr>
			<?php 
		    }?>
		    <tr>
		    	<td colspan = "3" align = "right">Total:</td>
		    	<td colspan = "4">$<?php echo $totalC?></td>
		    </tr>
	</table>
	
	<h3>Bank List (Total <?php echo count($this->bankList);?>)</h3>
	<table border="1" cellspacing="0" cellpadding="2" style="font-size:10px;">
		<tr>
			<td style="width:65px;">ID Bonus</td>
   			<td style="width:120px;">Staff</td>
    		<td style="width:150px;">Bonus Type</td>
    		<td style="width:100px;">Total Amt</td>
    		<td style="width:100px;">Pay Bank</td>
    		<td style="width:100px;">Super</td>
    		<td style="width:180px;">Period</td>
    		<td style="width:100px;">Will Pay On</td>
    		<td>Status</td>
		</tr>
		<?php foreach($this->bankList as $k => $v){
				$btypeRow = $btype->getStaffbonustype($v['type_bonus']);
		    	$sdRow = $stDetail->getDetail($v['id_staff']);
		    	$nName = $sdRow['ni'];
		    	$fName = Model_EncryptHelper::getSslPassword($sdRow['n']);
		    	?>
			<tr>
				<td><?php echo $v['id_bonus'];?></td>
				<td><?php echo ucwords($nName." <br />[ ".$fName." ]");?></td>
				<td><?php echo $btypeRow['type_bonus']?></td>
				<td align="left">$ <?php echo $v['amt_total_bonus']?></td>
				<td align="left">$ <?php echo $v['amt_bank_bonus']?></td>
    			<td align="left">$ <?php echo $v['amt_bonus_super']?></td>
				<td><?php echo $v['period_bonus_begin']." to ".$v['Period_bonus_end'];?></td>
				<td width="20"><?php echo $v['pay_date']?></td>
				<td><?php if($v['payment_status']== 'yes'){echo "PAID";}?></td>
				<?php $totalB += $v['amt_bank_bonus'];?>
			</tr>
			<?php 
		    }?>
		     <tr>
		    	<td colspan = "4" align = "right">Total:</td>
		    	<td colspan = "3">$<?php echo $totalB?></td>
		    </tr>
	</table>
	 <br/>
	 <br/>
	 <?php $totalAmt = $totalC + $totalB;?>
	 <h3>Total Amt:$<?php echo $totalAmt?></h3>


</form>

	<br/>
	

<input type = "submit" id = "next" name = "next" value = "Next" style = "margin-left:900px;" onclick= "transfer('<?php echo $this->dateBegin;?>','<?php echo $this->dateEnd;?>')"></input>


</body>
</html>

